package com.loan.config;

import com.loan.filter.CORSFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

/**
 * @Description:过滤器配置类
 * @Author:l
 * @Date:2022.01.18
 */
@Configuration
public class FilterConfig {

    /**
     * 配置跨域过滤器
     * @return
     */
    @Bean
    public FilterRegistrationBean<CORSFilter> filterFilterRegistrationBean() {
        FilterRegistrationBean<CORSFilter> filterFilterRegistrationBean = new FilterRegistrationBean<>();
        filterFilterRegistrationBean.setFilter(new CORSFilter());
        filterFilterRegistrationBean.addUrlPatterns("/*");
        filterFilterRegistrationBean.setOrder(1);
        return filterFilterRegistrationBean;
    }
}
